/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package strategy;

import java.util.ArrayList;

/**
 *
 * @author Kam
 */
public class ThreeToThree extends Strategy {

    private float mAnswer;

    public ThreeToThree(String tempSpecial, ArrayList<String> tempOtherStrings) {
        super(tempSpecial, tempOtherStrings);
        mAnswer = 0;
    }

    @Override
    protected void update() {
        Mediatior.getRef().update(this.mIndex);
    }

    @Override
    protected void end() {
        Mediatior.getRef().update(this.mIndex, String.valueOf(this.mAnswer));
    }

    @Override
    public void run() {
        int tempIdenticalChains = 0;
        for (int i = 0; i < (this.mSpecial.length() - 2); i++) {
            for (String stringFromArray : this.mOtherStrings) {
                if (this.mSpecial.substring(i, (i + 2)).equals(stringFromArray.substring(i, (i + 2)))) {
                    tempIdenticalChains++;
                    break;
                }
            }
        }
        this.mAnswer = ((float) tempIdenticalChains) / ((float) this.mSpecial.length());
    }
}
